import redis
import logging


class Config(object):
    """项目配置"""


    SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA"

    #为数据库配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/manage"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # redis配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    #Session保存配置
    SESSION_TYPE = 'redis'
    # 开启session签名
    SESSION_USE_SIGNER = True
    # 指定session保存的redis
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    #设置需要过期
    SESSION_PERMANENT = False
    # session 的有效期，秒
    PERMANENT_SESSION_LIFETIME = 86400 * 2

    #设置日志等级
    LOG_LEVEL = logging.DEBUG

class DevelopementConfig(Config):
    """开发模式下的配置"""
    DEBUG = True



class ProductionConfig(Config):
    """生产模式下的配置"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING

class TestingConfig(Config):
    DEBUG = True
    TESTING = True

config = {
    "development": DevelopementConfig,
    "production": ProductionConfig
}